package com.jit.app;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;


public class AppSearchActivity extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.activity_search);

        MainActivity.setAndroidNativeLightStatusBar(this,true);

        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.setTitle("");
        this.setSupportActionBar(toolbar);

        this.getSupportActionBar().setHomeButtonEnabled(true);
        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);


    }

    public static final int SEARCH_ID = 1;
    public static final int LABEL_ID = 2;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        MenuItem searchItem = menu.add(1,SEARCH_ID,1,"");
        SearchView searchView = new SearchView(this);
        searchView.setIconified(false);
        searchView.setBackground(getResources().getDrawable(R.drawable.bg_search));
        searchView.onActionViewExpanded();
        searchView.setMaxWidth(750);
        searchItem.setActionView(searchView);
        searchView.setQueryHint("提示信息");
        searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        MenuItem labelItem = menu.add(1,LABEL_ID,2,"搜索");
        labelItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);


        return super.onCreateOptionsMenu(menu);
    }
}
